from django.db import models
from .wechat_user import WechatUser

class OperationLog(models.Model):
    """
    操作日志模型
    """
    operation = models.CharField(max_length=255, verbose_name='操作内容')
    ip_address = models.GenericIPAddressField(verbose_name='IP地址')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    user = models.ForeignKey(WechatUser, on_delete=models.CASCADE, verbose_name='用户')

    class Meta:
        db_table = 'api_operationlog'
        verbose_name = '操作日志'
        verbose_name_plural = verbose_name
        ordering = ['-created_at']

    def __str__(self):
        return f"{self.user_id} - {self.operation} - {self.created_at}" 